package com.alibaba.datax.core;

import com.alibaba.datax.core.job.JobContainer;

import javax.xml.bind.SchemaOutputResolver;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class DataxTest {

    private static String dataxHome = "D:/idea-workspace/DataX/target/datax/datax";
//    private static List<String> jsonList = Arrays.asList("D:/idea-workspace/DataX/target/datax/datax/job/pgsql2pgsql_dataxsrc2dataxtarget.json",
//            "D:/idea-workspace/DataX/target/datax/datax/job/mysql2mysql_dataxsrc2dataxtarget.json");

//    private static List<String> jsonList = Arrays.asList("D:/idea-workspace/DataX/target/datax/datax/job/mysql2mysql_dataxsrc2dataxtarget.json",
//            "D:/idea-workspace/DataX/target/datax/datax/job/pgsql2pgsql_dataxsrc2dataxtarget.json");

//    private static List<String> jsonList = Arrays.asList("D:/idea-workspace/DataX/target/datax/datax/job/mysql2mysql_dataxsrc2dataxtarget.json");

//    private static List<String> jsonList = Arrays.asList("D:/idea-workspace/DataX/target/datax/datax/job/pgsql2pgsql_dataxsrc2dataxtarget.json");

    private static List<String> jsonList = Arrays.asList("D:/idea-workspace/DataX/target/datax/datax/job/job.json");

    /**
     * 测试java调用datax时报插件加载失败的异常
     * @param args
     */
    public static void main(String[] args) {
        System.setProperty("datax.home", dataxHome);


        for (String json : jsonList) {
            new Thread(()->{
                String[] datxArgs_raw = { "-job", json, "-mode", "standalone", "-jobid", "-1" };
                try {
                    Engine.entry(datxArgs_raw);
                } catch (Throwable throwable) {
                    throwable.printStackTrace();
                }
            }).start();

        }


//        Integer i1 = new Integer(7898);
//        Integer i2 = new Integer(7898);
//
//        System.out.println("i1 = "+i1.hashCode());
//        System.out.println("i2 = "+i2.hashCode());
    }
}
